import request from '@/utils/request'

// 获取帖子列表
export const getPostList = (params) => {
  return request({
    url: '/post/list',
    method: 'get',
    params
  })
}

// 获取帖子详情
export const getPostDetail = (id) => {
  return request({
    url: `/post/${id}`,
    method: 'get'
  })
}

// 创建帖子
export const createPost = (data) => {
  return request({
    url: '/post/create',
    method: 'post',
    data
  })
}

// 删除帖子
export const deletePost = (id) => {
  return request({
    url: `/post/${id}`,
    method: 'delete'
  })
}

// 点赞帖子
export const likePost = (id) => {
  return request({
    url: `/post/${id}/like`,
    method: 'post'
  })
}

// 取消点赞
export const unlikePost = (id) => {
  return request({
    url: `/post/${id}/unlike`,
    method: 'post'
  })
}